

<%@ page import="com.gasstation.GasSales" %>
<html>
    <head>
    <calendar:resources lang="en" theme="tiger"/>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'gasSales.label', default: 'Gas Daily Sales')}" />
        <title><g:message code="default.create.label" args="[entityName]" /></title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
            <span class="menuButton"><g:link class="list" action="listAsPerMonth"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
        </div>
        <div class="body">
            <h1><g:message code="default.create.label" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${gasSalesInstance}">
            <div class="errors">
                <g:renderErrors bean="${gasSalesInstance}" as="list" />
            </div>
            </g:hasErrors>
            <g:javascript library="prototype" />
            <script>
			function submitCreate(){
				document.forms['create'].transactionOnStr.value = document.forms['save'].transactionOn_value.value;
				document.forms['save'].transactionOnStr.value = document.forms['save'].transactionOn_value.value;
				document.forms['create'].submit();
			}
			</script>
			<g:form id="create" name="create" action="create" >
				<g:hiddenField name="transactionOnStr" value="${transactionOnStr}"/>
			</g:form>
            <g:form id="save" name="save" action="save" >
                <div class="dialog">
                    <table>
                        <tbody>
                         	<tr class="prop">
                                <td valign="top" class="name">
                                    <label for="transactionOn">Date</label>
                                </td>
                                <td colspan="5" valign="top">
                                <calendar:datePicker name="transactionOn" defaultValue="${new Date()}" value="${transactionOn}" dateFormat="%m/%d/%Y"
                                onChange= "javascript:submitCreate()"/>
                                <g:hiddenField name="transactionOnStr" value="${transactionOnStr}"/>
                                </td>
                            </tr>
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="regular"><g:message code="gasSales.regular.label" default="Regular" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: gasSalesInstance, field: 'regularNetGallons', 'errors')}">
                                     Gal <g:textField name="regularNetGallons" value="${gasSalesInstance?.regularNetGallons}"/>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: gasSalesInstance, field: 'regularPricePerGallon', 'errors')}">
                                	Price/Gal $<g:textField name="regularPricePerGallon" value="${session?.regSalesPricePerGallon==null?gasSalesInstance?.regularPricePerGallon:session?.regSalesPricePerGallon}"/>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: gasSalesInstance, field: 'regularOpenGallon', 'errors')}">
                                	<g:if test="${showOpenActualInvCostField.showRegularOpenGallonsField}">
                                     	Open Gal <g:textField name="regularOpenGallons"/>
                                    </g:if>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: gasSalesInstance, field: 'regularOpenInvCost', 'errors')}">
                                	<g:if test="${showOpenActualInvCostField.showRegularOpenInvCostField}">
                                	Open Inv Cost $<g:textField name="regularOpenInvCost"/>
                                	</g:if>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: gasSalesInstance, field: 'regularActualGallon', 'errors')}">
                                     Actual Gal <g:textField name="regularActualGallons" value="${regularActualGallons}"/>
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="midGrade"><g:message code="gasSales.midGrade.label" default="Mid Grade" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: gasSalesInstance, field: 'midGradeNetGallons', 'errors')}">
                                	Gal <g:textField name="midGradeNetGallons" value="${gasSalesInstance?.midGradeNetGallons}"/>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: gasSalesInstance, field: 'midGradePricePerGallon', 'errors')}">
                                	Price/Gal $<g:textField name="midGradePricePerGallon" value="${session?.midSalesPricePerGallon==null?gasSalesInstance?.midGradePricePerGallon:session?.midSalesPricePerGallon}"/>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: gasSalesInstance, field: 'midGradeOpenGallon', 'errors')}">
                                     <g:if test="${showOpenActualInvCostField.showMidGradeOpenGallonsField}">
                                     Open Gal <g:textField name="midGradeOpenGallons"/>
                                     </g:if>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: gasSalesInstance, field: 'midGradeOpenInvCost', 'errors')}">
                                	<g:if test="${showOpenActualInvCostField.showMidGradeOpenInvCostField}">
                                	Open Inv Cost $<g:textField name="midGradeOpenInvCost"/>
                                	</g:if>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: gasSalesInstance, field: 'midGradeActualGallon', 'errors')}">
                                     Actual Gal <g:textField name="midGradeActualGallons" value="${midGradeActualGallons}"/>
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="premium"><g:message code="gasSales.premium.label" default="Premium" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: gasSalesInstance, field: 'premiumNetGallons', 'errors')}">
                                    Gal <g:textField name="premiumNetGallons" value="${gasSalesInstance?.premiumNetGallons}"/>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: gasSalesInstance, field: 'premiumPricePerGallon', 'errors')}">
                                	Price/Gal $<g:textField name="premiumPricePerGallon" value="${session?.premiumSalesPricePerGallon==null?gasSalesInstance?.premiumPricePerGallon:session?.premiumSalesPricePerGallon}"/>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: gasSalesInstance, field: 'premiumOpenGallon', 'errors')}">
                                     <g:if test="${showOpenActualInvCostField.showPremiumOpenGallonsField}">
                                     Open Gal <g:textField name="premiumOpenGallons"/>
                                     </g:if>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: gasSalesInstance, field: 'premiumOpenInvCost', 'errors')}">
                                	<g:if test="${showOpenActualInvCostField.showPremiumOpenInvCostField}">
                                	Open Inv Cost $<g:textField name="premiumOpenInvCost"/>
                                	</g:if>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: gasSalesInstance, field: 'premiumActualGallon', 'errors')}">
                                     Actual Gal <g:textField name="premiumActualGallons"  value="${premiumActualGallons}"/>
                                </td>
                            </tr>
                        
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:submitButton name="create" class="save" value="Save" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
